package test;

import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

public class RemoteHTNodeClient {

  /**
   * Main method.
   * @param the_args the arguments.
   */
  public static void main(final String[] the_args) {

    // get the registry info - host, port, name

    // get a reference to the remote registry.

    final String host = the_args[0];
    final int port = Integer.parseInt(the_args[1]);
    final String registry_name = the_args[2];

    try {
      final Registry bootstrap = LocateRegistry.getRegistry(host, port);
      final Registry registry = (Registry) bootstrap.lookup(registry_name);
      final String[] registered_nodes = registry.list();

      System.out.println("List of registered nodes:");
      for (int i = 0; i < registered_nodes.length; i++) {
        System.out.println("Node registered: " + registered_nodes[i]);
      }

      // now we can as user to pick a server_node to start servicing queries from.
      System.out.println("Please select a node id to query(Enter Integer Value " +
          "from Node IDs available): ");

      // do stuff with the registry.
    } catch (RemoteException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (NotBoundException e) { 
      // TODO Auto-generated catch block
      e.printStackTrace();
    }


  }

}
